﻿using Microsoft.ServiceModel.Web;
using System;
using System.ServiceModel;
using System.ServiceModel.Web;

namespace Hbrs.Soa.Restclient.SingletonService
{
    [ServiceContract]
    public interface ISingletonService<TItem> where TItem : Book
    {
        [WebHelp(Comment = "Initializes the item based on the incoming JSON.")]
        [WebInvoke(Method = "POST", UriTemplate = "?format=json", ResponseFormat = WebMessageFormat.Json)]
        [OperationContract]
        TItem AddItemInJson(TItem initialValue);
        [OperationContract]
        [WebInvoke(Method = "POST", UriTemplate = "")]
        [WebHelp(Comment = "Initializes the item based on the incoming XML.")]
        TItem AddItemInXml(TItem initialValue);
        [OperationContract]
        [WebHelp(Comment = "Deletes the item.")]
        [WebInvoke(Method = "DELETE", UriTemplate = "")]
        void DeleteItem();
        [WebGet(UriTemplate = "?format=json", ResponseFormat = WebMessageFormat.Json)]
        [OperationContract]
        [WebHelp(Comment = "Returns the item in JSON format.")]
        TItem GetItemInJson();
        [OperationContract]
        [WebGet(UriTemplate = "")]
        [WebHelp(Comment = "Returns the item in XML format.")]
        TItem GetItemInXml();
        [OperationContract]
        [WebInvoke(Method = "PUT", UriTemplate = "?format=json", ResponseFormat = WebMessageFormat.Json)]
        [WebHelp(Comment = "Edits the item based on the incoming JSON and returns the updated item in JSON format.")]
        TItem UpdateItemInJson(TItem newValue);
        [WebInvoke(Method = "PUT", UriTemplate = "")]
        [OperationContract]
        [WebHelp(Comment = "Edits the item based on the incoming XML and returns the updated item in XML format.")]
        TItem UpdateItemInXml(TItem newValue);
    }
}
